﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CoreRp.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    [Filters.AuthRole]
    public class RoleController : ControllerBase
    {
        public RoleController(IFreeSql db)
        {
            this.Db = db;
        }

        public IFreeSql Db { get; }
        [HttpGet("page")]
        public LyaUIPageModel<Db_Models.RAP_ROLE> Get([FromQuery]int page ,[FromQuery]int limit)
        {
            var pm = new LyaUIPageModel<Db_Models.RAP_ROLE>();
            try
            {
                pm.data = Db.Select<Db_Models.RAP_ROLE>().Count(out long count).Page(page, limit).ToList();
                pm.count = count;
                pm.code = 0;
                pm.msg = "查询成功";
            }catch(Exception ex)
            {
                pm.count = 1;
                pm.msg = "查询失败" + ex.Message;
            }
            return pm;
        }
    }
}
